package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiantu.api.entity.DeviceBean;
import com.qiantu.api.entity.MemberBean;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;
import com.qiantu.phone.app.AppApplication;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MemberDataAdapter extends AppAdapter<MemberBean>{
    public MemberDataAdapter(Context context){
        super(context);
    }

    @NonNull
    @Override
    public MemberDataAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
        return new MemberDataAdapter.ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private TextView memberName;
        private TextView memberPhone;

        private ViewHolder() {
            super(R.layout.member_item);
            memberName = findViewById(R.id.name);
            memberPhone = findViewById(R.id.phone);
        }

        @Override
        public void onBindView(int position) {
            MemberBean memberBean = getItem(position);
            if (memberBean.getUserState() == -1) {
                memberName.setText(memberBean.getUserPhone());
                memberPhone.setText(R.string.not_regist_member);
            } else {
                if (AppApplication.getInstance().getLoginInfo().getUserInfo().getUserSerialNo().equals(memberBean.getUserSerialNo())) {
                    memberName.setTextColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
                    memberName.setText(memberBean.getUserNickName() + " (我)");
                } else {
                    memberName.setTextColor(AppApplication.getInstance().getThemeColor(R.attr.secondaryColor6));
                    memberName.setText(memberBean.getUserNickName());
                }
                memberPhone.setText(memberBean.getUserPhone());
            }
        }

    }
}